    {layout name="common/layout" /}
	
 

<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>

<div class="Hui-article-box" style="margin-top: 37px;">
  <div class="breadcrumb"><i class="Hui-iconfont"></i>商品
  <span class="c-gray en">&gt;</span> 修改商品详情模板 <span class="c-gray en">&gt;</span> 
  </div>
  <div class="Hui-article">
      <div style="height: 100px;border:1px solid #ccc;" class="mac">
        <div style="margin-left: 30px;">
          <h3>修改商品详情模板</h3>
          <span>商品/商品详情模板/<span style="font-weight: bold;font-size: 16px;">修改商品详情模板</span></span>
        </div>
      </div>
      <form action="" style="height: 700px;">
      <input type="hidden" name="goods_details_id" value="{$data['goods_details_id']}">
          <div class="mac" style="width: 920px;">
            <div style="padding:15px 0 0 30px;">
              <span>商品详情模板名称：</span>
              <input type="text" value="{$data['goods_details_name']}" name="goods_details_name" class="input-text radius size-M  ">
            </div>
             
           	     <div class="cl">
							<div class="f-l" style="margin-left: 30px;"><span>商品详情模板内容：</span></div>
							<div class="f-l" style="width:730px;margin-left: 34px;">
							
							            <input type="hidden" value="{$data['goods_details_image']}" id="goods_details_content" name="goods_details_content">
										<img id="img_goods" width="300px" height="300px" src="{$data['goods_details_content']}" onclick="$('#rentlist1').click()"/><br>
										<input  type="file" id="rentlist1" onchange="upload_goods_details('rentlist1')" name="imagefile1" style="margin-top: 10px;display:none;"/><br>
										<input  type="button" class="btn1" onclick="upload_goods_details('rentlist1');" value="上传"  style="margin:10px 0 20px 0px;display:none;"/>
							 
							 </div>
						</div>
						 <div style="padding:15px 0 0 30px;display:none;">
							<span>图片介绍：</span>
							 
							<input id="goods_details_text" value="{$data['goods_details_text']}" type="text" name="goods_details_text" class="input-text radius size-M  ">
						</div>
			<div class="btn-l">
              <input id="submitBtn" type="button" value="保存"  class="btn" >
              <button onclick="history.go(-1);" class="btn" style="margin-left: 20px;padding-top: -20px;">返回</button>
            </div>        
          </div>
      </form>
  </div>
</div>
 
<script> 
 
    $('#submitBtn').click(function(){
      var goods_details_name = $('input[name=goods_details_name]').val();
      var goods_details_content = $('#goods_details_content').val();
      var goods_details_text = $('input[name=goods_details_text]').val();
	  var goods_details_id = $('input[name=goods_details_id]').val();
      $.ajax({
          type: "POST",
          url: "<?php echo url('goodsdetails/update', '', false); ?>",
          dataType: 'json',
          cache: false,
          data: {'goods_details_name': goods_details_name,'goods_details_content': goods_details_content,'goods_details_text':goods_details_text,'goods_details_id':goods_details_id},
          success: function(data) {
            if(data.status == 1) 
            {
              layer.msg(data.msg,
                {time:1000,end: function(index, layero){
            location.href="{:url('goodsdetails/showlist')}";
            layer.close(index); 
          }});

            }else{
              layer.msg(data.msg);
            }

          },
          error: function(xhr, status, error) {
            console.log(xhr);
            console.log(status);
            console.log(error);
          }
        });
    });
    
	
	
function upload_goods_details( img_id ){
    var formData = new FormData();
	formData.append("file",$("#"+img_id+"")[0].files[0]);
	$.ajax({
		type:"post",
		url:"{:url('Goodsdetails/upload_img', '', false)}",
		async:true,
		cache: false,
	    data: formData,
	    processData: false,
	    contentType: false,
		data : formData,
		success : function(res){
	    	 $("#"+img_id+"").siblings("img").attr("src",res.data.access_url);
			 $("#"+img_id+"").siblings("img").siblings("input[type=hidden]").val(res.data.filename);
		},
		error : function(res){
			console.log(res.access_url);
			 
		}


	});
}

	
	
	
	
	
</script>
 